//
//  TabBarViewController.m
//  PropertyManager
//
//  Created by TNG on 2018/7/3.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "TabBarViewController.h"
#import "IndexViewController.h"
#import "PersonViewController.h"

@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    IndexViewController * index =[[IndexViewController alloc]init];
    UINavigationController * indexNVC =[self dsNavigationControllerAndRootCtr:index];
    indexNVC.title=@"首页";
    
    PersonViewController * person = [[PersonViewController alloc] init];
    UINavigationController * personNVC = [self dsNavigationControllerAndRootCtr:person];
    personNVC.title=@"个人";
    
    //设置未选中按钮图片
    UIImage * indexImg = [[UIImage imageNamed:@"home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * personImg = [[UIImage imageNamed:@"person"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    indexNVC.tabBarItem.image = indexImg;
    personNVC.tabBarItem.image = personImg;
    
    UIImage * indexSelectImg = [[UIImage imageNamed:@"HomeSelect"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * personSelectImg = [[UIImage imageNamed:@"PersonSelect"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    indexNVC.tabBarItem.selectedImage = indexSelectImg;
    personNVC.tabBarItem.selectedImage = personSelectImg;
    
    self.tabBarController.tabBar.backgroundColor=[UIColor whiteColor];
}

- (UINavigationController *)dsNavigationControllerAndRootCtr:(UIViewController *)ctr
{
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:ctr];
    [navigationController.navigationBar setTintColor:SFMNavBarColor];
    [navigationController.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:SFM153,NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
    [navigationController.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:SFMNavBarColor,NSForegroundColorAttributeName,nil] forState:UIControlStateSelected];
    [self addChildViewController:navigationController];
    return navigationController;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
